//1.对象
var a={
    "name":"xiaoming",
    "password":"123"
};
console.log(a);
//2.数组
var b=[
    {
    "name":"xiaoming",
    "password":"123"
    },{
    "name":"xiaoho",
    "password":"123"
    }
];
console.log(b);

//json对象和json字符串的转换
//json字符串
var c='{"name":"xiaoming","password":"123"}';//不能空格回车
console.log(c);
//json对象
var d={
    "name":"xiaoming",
    "password":"123"
};
console.log(d);
//字符串转换对象

var tt=[1,2,3,4,];
var aat=JSON.stringify(tt);
console.log(aat);

var student={
    name:'小明',
    age:20
}

var aas=JSON.stringify(student)///转换诚字符串，
//var aas=JSON.stringify(student,null,' ')//转换诚原表好像
console.log(aas);
//构造函数
function arr(name) {
    this.name=name,
    this.hello=function () {
        alert('hello'+this.name+'!')
    }
}
var tts=new arr('小红');
console.log(tts.hello());

function aad(x,y) {
    this.x=x;
    this.y=y;
    this.ttttf=function () {
        alert('现在已经'+this.x+'点了，欢迎'+this.y+'回家')
    }
}
var ggg=new aad(10,'小温')
console.log(ggg.ttttf());

let url = 'https://api.openweathermap.org/data/2.5/forecast?q=Beijing,cn&appid=800f49846586c3ba6e7052cfc89af16c';
var at=getJSON(url,function (data) {
    var info = {
        city: data.city.name,
        weather: data.list[0].weather[0].main,
        time: data.list[0].dt_txt
    };
    alert(JSON.stringify(info, null, '  '));

});
console.log(at);